<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>DiscontinuousGalerkin: SquareGrid.f90 Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">DiscontinuousGalerkin
   &#160;<span id="projectnumber">0.0.1</span>
   </div>
   <div id="projectbrief">Geração Acoplada de Discontinuous Galerkin</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Types&#160;List</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">SquareGrid.f90</div>  </div>
</div>
<div class="contents">
<a href="_square_grid_8f90.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a><a class="code" href="class_square_grid_manipulation.html">00001</a> <span class="keyword">module</span> <a class="code" href="class_square_grid_manipulation.html">SquareGridManipulation</a>
<a name="l00002"></a>00002     use <span class="keywordflow">SquareElementManipulation</span>
<a name="l00003"></a>00003     <span class="keyword">implicit none</span>
<a name="l00004"></a>00004 
<a name="l00005"></a><a class="code" href="struct_square_grid_manipulation_1_1_square_grid.html">00005</a>     <span class="keyword">type</span> <a class="code" href="struct_square_grid_manipulation_1_1_square_grid.html">SquareGrid</a>
<a name="l00006"></a><a class="code" href="struct_square_grid_manipulation_1_1_square_grid.html#a7327a0f28e77805ca863dd3bacf22fee">00006</a>         <span class="keywordtype">integer</span> :: Nelx
<a name="l00007"></a><a class="code" href="struct_square_grid_manipulation_1_1_square_grid.html#ad6bfdc70873fb9a5c5120b55ff38799f">00007</a>         <span class="keywordtype">integer</span> :: Nely
<a name="l00008"></a>00008 
<a name="l00009"></a><a class="code" href="struct_square_grid_manipulation_1_1_square_grid.html#a6618832069da6bc7deac0f7f82fb234e">00009</a>         <span class="keywordtype">real(kind=8)</span> :: Lx
<a name="l00010"></a><a class="code" href="struct_square_grid_manipulation_1_1_square_grid.html#a4786c346452118f596343027e477457b">00010</a>         <span class="keywordtype">real(kind=8)</span> :: Ly
<a name="l00011"></a>00011 
<a name="l00012"></a><a class="code" href="struct_square_grid_manipulation_1_1_square_grid.html#a1fd06040dd1eb4e633678a6061a5426f">00012</a>         <span class="keywordtype">real(kind=8)</span> :: Basex
<a name="l00013"></a><a class="code" href="struct_square_grid_manipulation_1_1_square_grid.html#a830fc1a147e1f338c1f5041c58b6f558">00013</a>         <span class="keywordtype">real(kind=8)</span> :: Basey
<a name="l00014"></a>00014 
<a name="l00015"></a><a class="code" href="struct_square_grid_manipulation_1_1_square_grid.html#a1df78ddd58f18947208f2c219483dc4f">00015</a>         <span class="keywordtype">type(SquareElement)</span>, <span class="keywordtype">dimension(:)</span>, <span class="keywordtype">allocatable</span> :: Elements
<a name="l00016"></a><a class="code" href="struct_square_grid_manipulation_1_1_square_grid.html#a7a869e31f0787ed5b0d72ec54fe2687c">00016</a>         <span class="keywordtype">real(kind=8)</span>, <span class="keywordtype">dimension(:,:)</span>, <span class="keywordtype">allocatable</span>      :: Nodes
<a name="l00017"></a><a class="code" href="struct_square_grid_manipulation_1_1_square_grid.html#a34ec7085e1e597d8dcfcab6a80db9997">00017</a>         <span class="keywordtype">integer</span>, <span class="keywordtype">dimension(:,:)</span>, <span class="keywordtype">allocatable</span>           :: Neighbours
<a name="l00018"></a>00018 
<a name="l00019"></a><a class="code" href="struct_square_grid_manipulation_1_1_square_grid.html#a9d1d0d75b8d7d2273b859acd420201de">00019</a>         <span class="keywordtype">integer</span>, <span class="keywordtype">dimension(:,:)</span>, <span class="keywordtype">allocatable</span>            :: BoundaryEdges
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 <span class="keyword">    end type</span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="keyword">contains</span>
<a name="l00024"></a>00024 
<a name="l00025"></a><a class="code" href="class_square_grid_manipulation.html#afd1b8de37642e275308edc4b5c35aa96">00025</a>     <span class="keyword">subroutine </span>SetGridData( this, Lx, Ly, Nelx, Nely, Basex, Basey)
<a name="l00026"></a>00026         <span class="keyword">implicit none</span>
<a name="l00027"></a>00027         <span class="keywordtype">type(SquareGrid)</span>, <span class="keywordtype">intent(out)</span> :: this
<a name="l00028"></a>00028         <span class="keywordtype">real(kind=8)</span>, <span class="keywordtype">intent(in)</span> :: Lx
<a name="l00029"></a>00029         <span class="keywordtype">real(kind=8)</span>, <span class="keywordtype">intent(in)</span> :: Ly
<a name="l00030"></a>00030         <span class="keywordtype">integer</span>, <span class="keywordtype">intent(in)</span> :: Nelx
<a name="l00031"></a>00031         <span class="keywordtype">integer</span>, <span class="keywordtype">intent(in)</span> :: Nely
<a name="l00032"></a>00032         <span class="keywordtype">real(kind=8)</span>, <span class="keywordtype">intent(in)</span> :: Basex
<a name="l00033"></a>00033         <span class="keywordtype">real(kind=8)</span>, <span class="keywordtype">intent(in)</span> :: Basey
<a name="l00034"></a>00034 
<a name="l00035"></a>00035         this%Nelx = Nelx
<a name="l00036"></a>00036         this%Nely = Nely
<a name="l00037"></a>00037         this%Lx = Lx
<a name="l00038"></a>00038         this%Ly = Ly
<a name="l00039"></a>00039         this%Basex = Basex
<a name="l00040"></a>00040         this%Basey = Basey
<a name="l00041"></a>00041 <span class="keyword">    end subroutine</span>
<a name="l00042"></a>00042 
<a name="l00043"></a><a class="code" href="class_square_grid_manipulation.html#a0e566169bc839b22ad63fbe68cf80d39">00043</a>     <span class="keyword">subroutine </span>GenerateStructuredGrid( this )
<a name="l00044"></a>00044         <span class="keyword">implicit none</span>
<a name="l00045"></a>00045         <span class="keywordtype">type(SquareGrid)</span>, <span class="keywordtype">intent(inout)</span> :: this
<a name="l00046"></a>00046 
<a name="l00047"></a>00047         call GenerateNodes(this)
<a name="l00048"></a>00048 
<a name="l00049"></a>00049         call GenerateElements(this)
<a name="l00050"></a>00050 
<a name="l00051"></a>00051         call GenerateNeighbours(this)
<a name="l00052"></a>00052 <span class="keyword">    end subroutine</span>
<a name="l00053"></a>00053 
<a name="l00054"></a><a class="code" href="class_square_grid_manipulation.html#a6b7bfbc3a2a7792e61ae5356aeff3f53">00054</a>     <span class="keyword">subroutine </span>GenerateNodes( this )
<a name="l00055"></a>00055         <span class="keyword">implicit none</span>
<a name="l00056"></a>00056         <span class="keywordtype">type(SquareGrid)</span>, <span class="keywordtype">intent(inout)</span> :: this
<a name="l00057"></a>00057 
<a name="l00058"></a>00058         <span class="keywordtype">integer</span> :: i, j
<a name="l00059"></a>00059         <span class="keywordtype">integer</span> :: statReturn
<a name="l00060"></a>00060 
<a name="l00061"></a>00061         <span class="keywordtype">real(kind=8)</span> :: dx, dy
<a name="l00062"></a>00062 
<a name="l00063"></a>00063         <span class="keyword">allocate</span>(this%Nodes( (this%Nelx+1)*(this%Nely+1), 2 ), stat=statReturn )
<a name="l00064"></a>00064         <span class="keyword">if</span>( statReturn /= 0 ) <span class="keyword">then</span>
<a name="l00065"></a>00065             print *, <span class="stringliteral">&#39;Unable to allocate memory for Nodes. NumbNodes = &#39;</span>, (this%Nelx+1)*(this%Nely+1)
<a name="l00066"></a>00066             return
<a name="l00067"></a>00067         <span class="keyword">end if</span>
<a name="l00068"></a>00068 
<a name="l00069"></a>00069         dx = this%Lx/this%Nelx
<a name="l00070"></a>00070         dy = this%Ly/this%Nely
<a name="l00071"></a>00071 
<a name="l00072"></a>00072         forall( i = 1:(this%Nely+1), j = 1:(this%Nelx+1) )
<a name="l00073"></a>00073             this%Nodes( (i - 1)*(this%Nelx+1) + j ,1) = this%Basex + (j-1)*dx
<a name="l00074"></a>00074             this%Nodes( (i - 1)*(this%Nelx+1) + j ,2) = this%Basey + (i-1)*dy
<a name="l00075"></a>00075         <span class="keyword">end</span> forall
<a name="l00076"></a>00076 <span class="keyword">    end subroutine</span>
<a name="l00077"></a>00077 
<a name="l00078"></a><a class="code" href="class_square_grid_manipulation.html#a36ed2d10da636b3a0db710fb8ac98926">00078</a>     <span class="keyword">subroutine </span>GenerateElements(this)
<a name="l00079"></a>00079         <span class="keyword">implicit none</span>
<a name="l00080"></a>00080         <span class="keywordtype">type(SquareGrid)</span>, <span class="keywordtype">intent(inout)</span> :: this
<a name="l00081"></a>00081 
<a name="l00082"></a>00082         <span class="keywordtype">integer</span> :: i, j
<a name="l00083"></a>00083         <span class="keywordtype">integer</span> :: statReturn
<a name="l00084"></a>00084 
<a name="l00085"></a>00085         <span class="keyword">allocate</span>(this%Elements((this%Nelx)*(this%Nely)), stat=statReturn )
<a name="l00086"></a>00086         <span class="keyword">if</span>( statReturn /= 0 ) <span class="keyword">then</span>
<a name="l00087"></a>00087             print *, <span class="stringliteral">&#39;Unable to allocate memory for Elements. NumbElements = &#39;</span>, (this%Nelx)*(this%Nely)
<a name="l00088"></a>00088             return
<a name="l00089"></a>00089         <span class="keyword">end if</span>
<a name="l00090"></a>00090 
<a name="l00091"></a>00091         forall( i = 1:this%Nely, j = 1:this%Nelx)
<a name="l00092"></a>00092             this%Elements( (i-1)*(this%Nelx) + j )%Nodes(1) = (i-1)*(this%Nelx) + j      <span class="comment">! SW node</span>
<a name="l00093"></a>00093             this%Elements( (i-1)*(this%Nelx) + j )%Nodes(2) = (i-1)*(this%Nelx) + j + 1  <span class="comment">! SE node</span>
<a name="l00094"></a>00094             this%Elements( (i-1)*(this%Nelx) + j )%Nodes(3) = (i)  *(this%Nelx) + j      <span class="comment">! NE node</span>
<a name="l00095"></a>00095             this%Elements( (i-1)*(this%Nelx) + j )%Nodes(4) = (i)  *(this%Nelx) + j + 1  <span class="comment">! NW node</span>
<a name="l00096"></a>00096         <span class="keyword">end</span> forall
<a name="l00097"></a>00097 <span class="keyword">    end subroutine</span>
<a name="l00098"></a>00098 
<a name="l00099"></a><a class="code" href="class_square_grid_manipulation.html#a8974c94a9203d2f3c33477d44a704f99">00099</a>     <span class="keyword">subroutine </span>GenerateNeighbours(this)
<a name="l00100"></a>00100         <span class="keyword">implicit none</span>
<a name="l00101"></a>00101         <span class="keywordtype">type(SquareGrid)</span>, <span class="keywordtype">intent(inout)</span> :: this
<a name="l00102"></a>00102 
<a name="l00103"></a>00103         <span class="keywordtype">integer</span> :: i, j
<a name="l00104"></a>00104         <span class="keywordtype">integer</span> :: n
<a name="l00105"></a>00105 
<a name="l00106"></a>00106         <span class="keywordtype">integer</span> :: statReturn
<a name="l00107"></a>00107 
<a name="l00108"></a>00108         <span class="keyword">allocate</span>(this%Neighbours((this%Nelx)*(this%Nely), 4), stat=statReturn )
<a name="l00109"></a>00109         <span class="keyword">if</span>( statReturn /= 0 ) <span class="keyword">then</span>
<a name="l00110"></a>00110             print *, <span class="stringliteral">&#39;Unable to allocate memory for Neighbours Elements. NumbNeighElements = &#39;</span>, (this%Nelx)*(this%Nely)*4
<a name="l00111"></a>00111             return
<a name="l00112"></a>00112         <span class="keyword">end if</span>
<a name="l00113"></a>00113 
<a name="l00114"></a>00114         this%Neighbours = 0
<a name="l00115"></a>00115 
<a name="l00116"></a>00116         <span class="keyword">do</span> i = 1, this%Nely
<a name="l00117"></a>00117             <span class="keyword">do</span> j = 1, this%Nelx
<a name="l00118"></a>00118                 n = (i-1)*(this%Nelx) + j
<a name="l00119"></a>00119                 <span class="keyword">if</span>(i /= 1)         this%Neighbours(n,1) = (i-2)*(this%Nelx) + j      <span class="comment">! Southern Neighbour</span>
<a name="l00120"></a>00120                 <span class="keyword">if</span>(j /= this%Nelx) this%Neighbours(n,2) = (i-1)*(this%Nelx) + j + 1  <span class="comment">! Eastern Neighbour</span>
<a name="l00121"></a>00121                 <span class="keyword">if</span>(i /= this%Nely) this%Neighbours(n,3) = (i)*(this%Nelx) + j        <span class="comment">! Nothern Neighbour</span>
<a name="l00122"></a>00122                 <span class="keyword">if</span>(j /= 1)         this%Neighbours(n,4) = (i-1)*(this%Nelx) + j - 1  <span class="comment">! Western Neighbour</span>
<a name="l00123"></a>00123             <span class="keyword">end do</span>
<a name="l00124"></a>00124         <span class="keyword">end do</span>
<a name="l00125"></a>00125 <span class="keyword">    end subroutine</span>
<a name="l00126"></a>00126 
<a name="l00127"></a><a class="code" href="class_square_grid_manipulation.html#a84e1eb3649ba00063ec1b457626285c4">00127</a>     <span class="keyword">subroutine </span>GenerateBoundaryEdges(this)
<a name="l00128"></a>00128         <span class="keyword">implicit none</span>
<a name="l00129"></a>00129         <span class="keywordtype">type(SquareGrid)</span>, <span class="keywordtype">intent(inout)</span> :: this
<a name="l00130"></a>00130 
<a name="l00131"></a>00131         <span class="keywordtype">integer</span> :: i, n
<a name="l00132"></a>00132 
<a name="l00133"></a>00133         <span class="keywordtype">integer</span> :: statReturn
<a name="l00134"></a>00134 
<a name="l00135"></a>00135         n = 2*(this%Nelx+this%Nely)
<a name="l00136"></a>00136         <span class="keyword">allocate</span>(this%BoundaryEdges(n,2), stat=statReturn )
<a name="l00137"></a>00137         <span class="keyword">if</span>( statReturn /= 0 ) <span class="keyword">then</span>
<a name="l00138"></a>00138             print *, <span class="stringliteral">&#39;Unable to allocate memory for Boundary Edge Elements. NumbBoundEdges = &#39;</span>, (this%Nelx+this%Nely)*2
<a name="l00139"></a>00139             return
<a name="l00140"></a>00140         <span class="keyword">end if</span>
<a name="l00141"></a>00141 
<a name="l00142"></a>00142         this%BoundaryEdges = 0
<a name="l00143"></a>00143 
<a name="l00144"></a>00144         <span class="keyword">do</span> i = 1, this%Nelx
<a name="l00145"></a>00145             this%BoundaryEdges(i,1) = i
<a name="l00146"></a>00146             this%BoundaryEdges(i+this%Nely,1) = (this%Nelx*this%Nely) - (i-1)
<a name="l00147"></a>00147         <span class="keyword">end do</span>
<a name="l00148"></a>00148         <span class="keyword">do</span> i = 1, this%Nely
<a name="l00149"></a>00149             this%BoundaryEdges(this%Nelx+i,1) = this%Nelx * i
<a name="l00150"></a>00150             this%BoundaryEdges(i+2*this%Nelx+this%Nely ,1) = (this%Nelx*this%Nely) - i * this%Nelx + 1
<a name="l00151"></a>00151         <span class="keyword">end do</span>
<a name="l00152"></a>00152 <span class="keyword">    end subroutine</span>
<a name="l00153"></a>00153 
<a name="l00154"></a>00154 <span class="keyword">end module</span>
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Wed May 23 2012 11:59:07 for DiscontinuousGalerkin by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
